﻿using DeltaEngine.Content;
using DeltaEngine.Core;
using DeltaEngine.Platforms;
using DeltaEngine.Platforms.All;
using DeltaEngine.Rendering.ScreenSpaces;
using NUnit.Framework;
using System;
using System.Collections.Generic;

namespace DeltaNinja.Tests.Entities
{
	internal class LogoTests : TestWithAllFrameworks
	{
		[VisualTest]
		public void CreateLogos(Type resolver)
		{
			Start(resolver,
				(ContentLoader contentLoader, PseudoRandom randomizer, LogoFactory factory) =>
				{
					var logos = new List<Logo>();

					var n = randomizer.Get(10, 100);
					for (int i = 0; i < n; i++)
					{
						var logo = factory.Create();
						if(logo != null)
							logos.Add(logo);
					}
										
					Assert.IsTrue(logos.Count == n);
				});
		}

		[VisualTest]
		public void ShowLogosAndWait(Type resolver)
		{
			Start(resolver,
				(ContentLoader contentLoader, LogoFactory factory, Window window, ScreenSpace screen) =>
				{
					var logos = new List<Logo>();

					var n = 10; // randomizer.Get(10, 100);
					for (int i = 0; i < n; i++)
					{
						var logo = factory.Create();
						if (logo != null)
							logos.Add(logo);
					}

					Assert.IsTrue(logos.Count == n);

					//if (mockResolver == null) return;

					//var time = Time.Current;

					//while(time.Milliseconds < 10000)					
					//{
					//	// mockResolver.input.SetMouseButtonState(MouseButton.Left, State.Releasing);
					//	mockResolver.AdvanceTimeAndExecuteRunners(1);

					//	// if (time.CheckEvery(1))
					//	{
					//		window.Title = "Logo count: " + logos.Count;

					//		logos.RemoveAll(x => x.IsOutside(screen.Viewport));
					//	}												
					//}

					//Assert.IsTrue(logos.Count == 0);
					//window.Dispose();					
				});
		}
	}
}
